package tdd.t1;

public class TaxiFeeSH extends TaxiFee {
	protected int iSecondMiles;
	protected double dDaytimePricePerMileSec;
	protected double dNightPricePerMileSec;
	TaxiFeeSH() {
		super();
		this.iSecondMiles = 10;
		this.dDaytimePricePerMileSec = 3.5;
		this.dNightPricePerMileSec = 4.7; 
	}
	
	TaxiFeeSH(TaxiFee feeBase,
			int iSecondMiles,
    		double dDaytimePricePerMileSec,
    		double dNightPricePerMileSec) {
		super(feeBase.iStartMiles,feeBase.iDaytimeStartTime,feeBase.dDaytimePricePerMile,feeBase.dDaytimeStartPrice,
				feeBase.iNightStartTime,feeBase.dNightPricePerMile,feeBase.dNightStartPrice);
		this.iSecondMiles = iSecondMiles;
		this.dDaytimePricePerMileSec = dDaytimePricePerMileSec;
		this.dNightPricePerMileSec = dNightPricePerMileSec; 
		}
	
	 public double chargeBySec(double miles,  double unitFeeStart, double unitFeeSec, double startPrice) {
		 return startPrice + (this.iSecondMiles - this.iStartMiles) * unitFeeStart +
			+ (Math.ceil(miles) - this.iSecondMiles) * unitFeeSec;
	 }
	
	 public double chargeByTime(double miles, int time) throws Exception {
		 if(Math.ceil(miles) > this.iSecondMiles) {
			 if(time>=this.iDaytimeStartTime&&time<this.iNightStartTime) {
				 return this.chargeBySec(miles, this.dDaytimePricePerMile, this.dDaytimePricePerMileSec, this.dDaytimeStartPrice);
			 } else {
				 return this.chargeBySec(miles, this.dNightPricePerMile, this.dNightPricePerMileSec, this.dNightStartPrice);
			 }
		 } else {
			 return super.chargeByTime(miles, time);
		 }
	 }
	
}
